﻿//链表分割
//struct ListNode* ghead, * gtail, * lhead, * ltail;
//ghead = gtail = (struct ListNode*)malloc(sizeof(struct ListNode));
//lhead = ltail = (struct ListNode*)malloc(sizeof(struct ListNode));
//struct ListNode* cur = pHead;
//while (cur) {
//	if (cur->val < x) {
//		ltail->next = cur;
//		ltail = ltail->next;
//	}
//	else {
//		gtail->next = cur;
//		gtail = gtail->next;
//	}
//	cur = cur->next;
//}
//ltail->next = ghead->next;
//gtail->next = NULL;
//struct ListNode* head = lhead->next;
//free(lhead);
//free(ghead);
//return head;
//输入两个链表，找出它们的第一个公共结点
// struct ListNode *getIntersectionNode(struct ListNode *headA, struct ListNode *headB) {
//assert(headA&& headB);
//int anum = 0, bnum = 0;
//struct ListNode* Atest = headA;
//struct ListNode* Btest = headB;
//while (Atest)
//{
//    Atest = Atest->next;
//    anum++;
//}
//while (Btest)
//{
//    Btest = Btest->next;
//    bnum++;
//}
//int n = abs(anum - bnum);
//Atest = headA;
//Btest = headB;
//if (anum < bnum)
//{
//    Atest = headB;
//    Btest = headA;
//}
//while (n--)
//{
//    Atest = Atest->next;
//}
//while (Atest != NULL && Btest != NULL)
//{
//    if (Atest == Btest)
//    {
//        return Atest;
//    }
//    Atest = Atest->next;
//    Btest = Btest->next;
//}
//return NULL;
//}
//.给定一个链表，返回链表开始入环的第一个节点。 如果链表无环，则返回 NULL
//struct ListNode* detectCycle(struct ListNode* head) {
//    if (head == NULL)
//    {
//        return false;
//    }
//    else
//    {
//        struct ListNode* slow = head;
//        struct ListNode* fast = head;
//        struct ListNode* sec = NULL;
//        while (fast && fast->next)
//        {
//            slow = slow->next;
//            fast = fast->next->next;
//           if (slow == fast)
//            {
//                sec = slow;
//                struct ListNode* begin = head;
//                while (begin != sec)
//                    begin = begin->next;
//                sec = sec->next;
//            }
//            return begin;
//        }
//    }
//    return false;
//}
//}